
def get_request_ip(func):
    def wrap(request, *args, **kwargs):
        if 'HTTP_X_FORWARDED_FOR' in request.META:
            ip = request.META.get('HTTP_X_FORWARDED_FOR')
        else:
            ip = request.META.get('REMOTE_ADDR')
        kwargs['req_ip'] = ip
        return func(request, *args, **kwargs)
    return wrap


